#ifndef _D12_
#define	_D12_
//Command summary

//Initialization commands

#define 	SET_ADDRESS					0xD0
#define		SET_ENDPOINT				0xD8
#define		SET_MODE					0xF3

//Data flow commands
#define		READ_INTREG					0xF4
//Select Endpoint
#define		SELECT_CONTROL_OUT			0x00
#define		SELECT_CONTROL_IN			0x01
#define		SELECT_ENDPOINT_1OUT		0x02
#define		SELECT_ENDPOINT_1IN			0x03
#define		SELECT_ENDPOINT_2OUT		0x04
#define		SELECT_ENDPOINT_2IN			0x05

//Read Last Transaction Status
#define		READ_CONTROL_OUT			0x40
#define		READ_CONTROL_IN				0x41
#define		READ_ENDPOINT_1OUT			0x42
#define		READ_ENDPOINT_1IN			0x43
#define		READ_ENDPOINT_2OUT			0x44
#define		READ_ENDPOINT_2IN			0x45

//Read Buffer
#define		READ_WRITE_BUFFER			0xF0
//#define		WRITE_BUFFER				0xF0
//Set Endpoint Status
#define		SET_CONTROL_OUT				0x40
#define		SET_CONTROL_IN				0x41
#define		SET_ENDPOINT_1OUT			0x42
#define		SET_ENDPOINT_1IN			0x43
#define		SET_ENDPOINT_2OUT			0x44
#define		SET_ENDPOINT_2IN			0x45

//Acknowledge Setup
#define		ACK_SETUP					0xF1
//Clear Buffer
#define		CLEAR_BUFFER				0xF2
//Validate Buffer
#define		VALIDATE_BUFFER				0xFA
//General commands
#define		SEND_RESUME					0xF6
#define		READ_FRAME_NUMBER			0xF5

//Read ID
#define		READ_ID						0xFD

extern void D12_WriteByte(uint8_t data);
extern void D12_WriteComm(uint8_t command);
extern uint8_t D12_ReadByte(void);
extern uint16_t D12_ReadID(void);
extern uint8_t D12_WriteBuffer(uint8_t endpoint1,uint8_t len,uint8_t *buffer);
extern void D12_SetMode(uint8_t data1, uint8_t data2);
extern uint8_t D12_ReadEndpointStatus(uint8_t endpoint);
extern uint8_t D12_ReadBuffer(uint8_t endpoint,uint8_t len, uint8_t *buffer);
extern void D12_ClearBuffer(void);
extern void D12_AcknowledgeSetup(void);
extern void D12_SetAddress(uint8_t address);
extern uint8_t D12_ReadEndpointStatus(uint8_t endpoint);
extern void D12_SetEndpointEnable(uint8_t enable);
#endif